/*
 * 价目表下拉列表
 * 参数   交易码：trancode=PriceList
 * 
 */

package org.ccams.tran;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import org.ccams.domain.TPricelist;
/**
 * 价目表下拉列表
 * @author 刘广帅
 *
 */
public class TranPriceList extends AbstractJsonTran {

	@SuppressWarnings("unchecked")
	public void buildJSONObject(Map model, JSONObject json,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		HashMap<String, Object> jsonMap = new HashMap<String, Object>();
		ArrayList<TPricelist> al = new ArrayList<TPricelist>();
		List<TPricelist> list = getCcamsService().getTpricelistDao().getAll();
		for(TPricelist t : list){
			TPricelist tm = new TPricelist();
			tm.setIdtPricelist(t.getIdtPricelist());
			tm.setNamelistName(t.getNamelistName());
			al.add(tm);
		}
		JSONArray JsonArray = JSONArray.fromObject(al); //得到JSON数组 
        jsonMap.put("root", JsonArray);
        json.putAll(jsonMap);
	}
}
